using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FiltronASP.Modules.Abstracts;
using FiltronASP.Models.DAO.Interfaces;
using FiltronASP.Models;
using FiltronASP.Models.DAO;
using FiltronASP.Helpers.Translations;

namespace FiltronASP.Modules
{
    public class partnersDropDownModule : AbstractModule
    {
        private Page currentPage;

        /// <summary>
        /// Klasa odpowiedzialna za generowanie contentu przez modul.
        /// </summary>
        /// <param name="page">biezaca strona</param>
        /// <returns>content</returns>
        public override string GenerateContent(FiltronASP.Models.Page page)
        {
            this.currentPage = page;
            int languageId = Convert.ToInt32(page.language_id);
            string optionsToReturn = "<option value=\"-1\">" + translationHelper.getTranslation("_selectCountry", 7) + "</option>";
            IPageDAO pageDAO = new PageDAO();
            IQueryable<Page> countriesCollection = pageDAO.FindByLanguageAndTemplateNameAndPublished(Convert.ToInt32(page.language_id), "singleCountry", true);
            if (countriesCollection != null) {
                countriesCollection = countriesCollection.OrderBy(p => p.page_name);
                foreach (Page singleCountry in countriesCollection) {
                    optionsToReturn += String.Format("<option value=\"{0}\">{1}</option>", singleCountry.page_link, singleCountry.page_name);
                }
            }
            return optionsToReturn;
        }
    }
}

// - pomapować regiony z mapy, w alt'y nazwa angielska